<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    $name = 'Wvv';
    $age = 18;
    $sex = '女';
    $data = '<alert>1234</alert>';

    //return view('welcome',['name'=>$name]);
    //return view('welcome')->with('name',$name);
    return view('welcome',compact('name','age','sex','data'));
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');


Route::get('tasks',function (){
    $tasks = DB::table('tasks')->latest()->get();
    return view('tasks.index',compact('tasks'));
});

Route::get('tasks/{task}',function ($id){
    $task = DB::table('tasks')->find($id);
    //return view('tasks.show',compact('task'));
    return view('tasks/show',compact('task'));
});


Route::get('tasks',function (){
    $completedTasks =  \App\Task::latest()->completed()->get();
    $unCompletedTasks =  \App\Task::latest()->unCompleted()->get();

    return view('tasks/index',compact('completedTasks','unCompletedTasks'));
});

Route::get('tasks/{task}',function ($id){
    $task = \App\Task::FindorFail($id);
    return view('tasks/show',compact('task'));
});


Route::get('tasks','TaskController@index');
Route::get('tasks/{task}','TaskController@show');

Route::get('/posts','PostsController@index')->name('home');
Route::get('/posts/create','PostsController@create');
Route::get('/posts/{post}','PostsController@show');
Route::post('/posts','PostsController@store');
Route::post('/posts/{post}/comment','CommentController@store');

Route::get('/register','RegistrationController@create');
Route::post('/register','RegistrationController@store');
Route::get('/sendActiveMail','RegistrationController@send');
Route::get('/activeAccount','RegistrationController@active');

Route::get('/login','SessionController@create');
Route::post('/login','SessionController@store');
Route::get('/logout','SessionController@destroy');


